@echo off
echo 📊 Nacos集群监控器
echo ==================
echo.

:monitor_loop
cls
echo 📊 集群状态监控 (%date% %time%)
echo ===========================
echo.

REM 检查每个节点
echo 🔍 节点状态检查:
echo.

echo 📍 节点1 (127.0.0.1:8848):
curl -s -m 2 http://localhost:8848/health > NUL
if %errorlevel%==0 (
    echo    ✅ 在线
    curl -s http://localhost:8848/health | find "OK" > NUL
) else (
    echo    ❌ 离线
)

echo 📍 节点2 (127.0.0.1:8849):
curl -s -m 2 http://localhost:8849/health > NUL
if %errorlevel%==0 (
    echo    ✅ 在线
    curl -s http://localhost:8849/health | find "OK" > NUL
) else (
    echo    ❌ 离线
)

echo 📍 节点3 (127.0.0.1:8850):
curl -s -m 2 http://localhost:8850/health > NUL
if %errorlevel%==0 (
    echo    ✅ 在线
    curl -s http://localhost:8850/health | find "OK" > NUL
) else (
    echo    ❌ 离线
)

echo 📍 节点4 (127.0.0.1:8851):
curl -s -m 2 http://localhost:8851/health > NUL
if %errorlevel%==0 (
    echo    ✅ 在线
    curl -s http://localhost:8851/health | find "OK" > NUL
) else (
    echo    ❌ 离线
)

echo.
echo 📈 服务实例统计:
echo.

REM 检查服务实例
curl -s "http://localhost:8848/nacos/v1/ns/instance/list?namespace=public&service_name=rust-service-1" > NUL
if %errorlevel%==0 (
    echo 📊 rust-service-1: 已注册
) else (
    echo 📊 rust-service-1: 未找到
)

curl -s "http://localhost:8848/nacos/v1/ns/instance/list?namespace=public&service_name=java-service-1" > NUL
if %errorlevel%==0 (
    echo 📊 java-service-1: 已注册
) else (
    echo 📊 java-service-1: 未找到
)

echo.
echo 🔄 5秒后刷新...
timeout /t 5 /nobreak > NUL
goto monitor_loop